"use strict";
exports.__esModule = true;
var Goods = /** @class */ (function () {
    function Goods(name, sellIn, quality) {
        this.sellIn = sellIn;
        this.quality = quality;
        this.name = name;
    }
    Goods.prototype.updateByDay = function () {
        if (this.name == 'cheese') {
            if (this.sellIn > 0) {
                // 没过保
                this.quality = this.quality + 1;
            }
            else {
                // 已过保
                this.quality = this.quality + 2;
            }
        }
        else if (this.name == 'normal') {
            if (this.sellIn <= 0) {
                this.quality = this.quality - 2;
            }
            else {
                this.quality = this.quality - 1;
            }
        }
        else if (this.name == 'ticket') {
            console.log(this.sellIn, this.quality);
            // 距离演出前10天之前，门票价值每天上升1点
            if (this.sellIn > 10)
                this.quality = this.quality + 1;
            // 距离演出5~10天时间范围内，门票价值每天上升2点
            if (this.sellIn <= 10 && this.sellIn > 5)
                this.quality = this.quality + 2;
            // 距离演出5天以内，门票价值每天上升3点
            if (this.sellIn <= 5 && this.sellIn >= 1)
                this.quality = this.quality + 3;
            // 到达演出当天，门票价值为0
            if (this.sellIn <= 0)
                this.quality = 0;
        }
        // 商品的价值永远不会小于0
        if (this.quality < 0)
            this.quality = 0;
        // 商品的价值永远不会大于50
        if (this.quality > 50)
            this.quality = 50;
        // 日常更新，保质期-1
        this.sellIn = this.sellIn - 1;
    };
    Goods.prototype.updateDouble = function () {
        this.sellIn = this.sellIn - 1;
        this.quality = this.quality - 2;
    };
    Goods.prototype.getSellIn = function () {
        return this.sellIn;
    };
    Goods.prototype.getQuality = function () {
        return this.quality;
    };
    return Goods;
}());
var quality = 20;
var sellIn = 15;
var goods = new Goods('ticket', sellIn, quality);
goods.updateByDay();
var updatedQuality = goods.getQuality();
var updatedSellIn = goods.getSellIn();
console.log(updatedQuality, updatedSellIn);
exports["default"] = Goods;
